var _n;
var cc__extends = __extends;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Spawn3d = exports.Sequence3d = exports.CallFun3d = exports.FadeBy = exports.FadeTo = exports.RotateBy3d = exports.RotateTo3d = exports.ScaleTo3d = exports.MoveBy3d = exports.MoveTo3d = exports.DelayTime = exports.FiniteTimeAction3d = exports.Action3d = undefined;
var def_Action3dManager = function () {
  function _ctor() {}
  _ctor.update = function (t) {
    for (var e = this.allActions.length - 1; e >= 0; --e) {
      this.allActions[e].update(t);
      this.allActions[e].finished && this.allActions.splice(e, 1);
    }
  };
  _ctor.runAction = function (t, e) {
    this.stopAllActions(t);
    if (e.binded) {
      console.warn("3D动作对象已绑定其他节点，当前节点无法运行该动作");
    } else {
      e.setTarget(t);
      this.allActions.push(e);
    }
  };
  _ctor.stopAllActions = function (t) {
    if (t) {
      for (var e = this.allActions.length - 1; e >= 0; --e) {
        this.allActions[e].node == t && this.allActions.splice(e, 1);
      }
    } else {
      this.allActions = [];
    }
  };
  _ctor.delay = function (t) {
    return new exp_DelayTime(t);
  };
  _ctor.moveTo = function (t, e, o, n) {
    return new exp_MoveTo3d(t, e, o, n);
  };
  _ctor.moveBy = function (t, e, o, n) {
    return new exp_MoveBy3d(t, e, o, n);
  };
  _ctor.scaleTo = function (t, e, o, n) {
    return new exp_ScaleTo3d(t, e, o, n);
  };
  _ctor.rotateTo = function (t, e, o, n) {
    return new exp_RotateTo3d(t, e, o, n);
  };
  _ctor.rotateBy = function (t, e, o, n) {
    return new exp_RotateBy3d(t, e, o, n);
  };
  _ctor.fadeTo = function (t, e) {
    return new exp_FadeTo(t, e);
  };
  _ctor.fadeBy = function (t, e) {
    return new exp_FadeBy(t, e);
  };
  _ctor.callFun = function (t, e, o) {
    return new exp_CallFun3d(t, e, o);
  };
  _ctor.sequence = function () {
    var t = [];
    for (var e = 0; e < arguments.length; e++) {
      t[e] = arguments[e];
    }
    return new exp_Sequence3d(t);
  };
  _ctor.spawn = function () {
    var t = [];
    for (var e = 0; e < arguments.length; e++) {
      t[e] = arguments[e];
    }
    return new exp_Spawn3d(t);
  };
  _ctor.easeIn = function (t) {
    return new S(t);
  };
  _ctor.easeOut = function (t) {
    return new b(t);
  };
  _ctor.easeInOut = function (t) {
    return new w(t);
  };
  _ctor.easeOutIn = function (t) {
    return new P(t);
  };
  _ctor.easeExponentialIn = function () {
    return new O();
  };
  _ctor.easeExponentialOut = function () {
    return new C();
  };
  _ctor.easeExponentialInOut = function () {
    return new N();
  };
  _ctor.allActions = [];
  return _ctor;
}();
exports.default = def_Action3dManager;
var exp_Action3d = function () {
  function t() {}
  Object.defineProperty(t.prototype, "binded", {
    get() {
      return !!this.node;
    },
    enumerable: false,
    configurable: true
  });
  t.prototype.setTarget = function (t) {
    this.node = t;
  };
  t.prototype.easing = function () {
    var t = [];
    for (var e = 0; e < arguments.length; e++) {
      t[e] = arguments[e];
    }
    this._easeList = [];
    var o = 0;
    for (var n = t.length; o < n; ++o) {
      this._easeList.push(t[o]);
    }
    return this;
  };
  t.prototype.computeEaseTime = function (t) {
    var e = this._easeList;
    if (!e || 0 === e.length) {
      return t;
    }
    var o = 0;
    for (var n = e.length; o < n; o++) {
      t = e[o].easing(t);
    }
    return t;
  };
  Object.defineProperty(t.prototype, "finished", {
    get() {
      return false;
    },
    enumerable: false,
    configurable: true
  });
  t.prototype.update = function () {};
  return t;
}();
exports.Action3d = exp_Action3d;
var exp_FiniteTimeAction3d = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o._paused = false;
    o.duration = e;
    o.elapse = 0;
    return o;
  }
  cc__extends(e, t);
  Object.defineProperty(e.prototype, "finished", {
    get() {
      return this.elapse >= this.duration;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(e.prototype, "paused", {
    get() {
      return this._paused;
    },
    enumerable: false,
    configurable: true
  });
  e.prototype.update = function (t) {
    var e = this.addElapseTime(t);
    this.step(e);
  };
  e.prototype.addElapseTime = function (t) {
    this.elapse += t;
    var e = 1;
    this.duration > 0 && (e = this.elapse / this.duration) > 1 && (e = 1);
    return this.computeEaseTime(e);
  };
  e.prototype.step = function () {};
  e.prototype.interpolation = function (t, e, o) {
    return t + (e - t) * o;
  };
  return e;
}(exp_Action3d);
exports.FiniteTimeAction3d = exp_FiniteTimeAction3d;
var exp_DelayTime = function (t) {
  function e() {
    return null !== t && t.apply(this, arguments) || this;
  }
  cc__extends(e, t);
  return e;
}(exp_FiniteTimeAction3d);
exports.DelayTime = exp_DelayTime;
var exp_MoveTo3d = function (t) {
  function e(e, o, n, i) {
    var r = t.call(this, e) || this;
    r.target = "number" == typeof o ? {
      x: o,
      y: n,
      z: i
    } : o;
    return r;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = {
      x: t.x,
      y: t.y,
      z: t.z
    };
  };
  e.prototype.step = function (t) {
    this.node.x = this.interpolation(this.original.x, this.target.x, t);
    this.node.y = this.interpolation(this.original.y, this.target.y, t);
    this.node.z = this.interpolation(this.original.z, this.target.z, t);
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.MoveTo3d = exp_MoveTo3d;
var exp_MoveBy3d = function (t) {
  function e(e, o, n, i) {
    var r = t.call(this, e) || this;
    r.target = "number" == typeof o ? {
      x: o,
      y: n,
      z: i
    } : o;
    return r;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = {
      x: t.x,
      y: t.y,
      z: t.z
    };
  };
  e.prototype.step = function (t) {
    this.node.x = this.original.x + this.target.x * t;
    this.node.y = this.original.y + this.target.y * t;
    this.node.z = this.original.z + this.target.z * t;
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.MoveBy3d = exp_MoveBy3d;
var exp_ScaleTo3d = function (t) {
  function e(e, o, n, i) {
    var r = t.call(this, e) || this;
    r.target = "number" == typeof o ? {
      x: o,
      y: n,
      z: i
    } : o;
    return r;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = {
      x: t.scaleX,
      y: t.scaleY,
      z: t.scaleZ
    };
  };
  e.prototype.step = function (t) {
    var e = this.interpolation(this.original.x, this.target.x, t);
    var o = this.interpolation(this.original.y, this.target.y, t);
    var n = this.interpolation(this.original.z, this.target.z, t);
    this.node.setScale(e, o, n);
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.ScaleTo3d = exp_ScaleTo3d;
var exp_RotateTo3d = function (t) {
  function e(e, o, n, i) {
    var r = t.call(this, e) || this;
    r.target = "number" == typeof o ? {
      x: o,
      y: n,
      z: i
    } : o;
    return r;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = {
      x: t.eulerAngles.x,
      y: t.eulerAngles.y,
      z: t.eulerAngles.z
    };
  };
  e.prototype.step = function (t) {
    var e = this.interpolation(this.original.x, this.target.x, t);
    var o = this.interpolation(this.original.y, this.target.y, t);
    var n = this.interpolation(this.original.z, this.target.z, t);
    this.node.eulerAngles = cc.v3(e, o, n);
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.RotateTo3d = exp_RotateTo3d;
var exp_RotateBy3d = function (t) {
  function e(e, o, n, i) {
    var r = t.call(this, e) || this;
    r.target = "number" == typeof o ? {
      x: o,
      y: n,
      z: i
    } : o;
    return r;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = {
      x: t.eulerAngles.x,
      y: t.eulerAngles.y,
      z: t.eulerAngles.z
    };
  };
  e.prototype.step = function (t) {
    var e = this.original.x + this.target.x * t;
    var o = this.original.y + this.target.y * t;
    var n = this.original.z + this.target.z * t;
    this.node.eulerAngles = cc.v3(e, o, n);
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.RotateBy3d = exp_RotateBy3d;
var exp_FadeTo = function (t) {
  function e(e, o) {
    var n = t.call(this, e) || this;
    n.target = o;
    return n;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = t.opacity;
  };
  e.prototype.step = function (t) {
    var e = this.interpolation(this.original, this.target, t);
    this.node.opacity = e;
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.FadeTo = exp_FadeTo;
var exp_FadeBy = function (t) {
  function e(e, o) {
    var n = t.call(this, e) || this;
    n.target = o;
    return n;
  }
  cc__extends(e, t);
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.original = t.opacity;
  };
  e.prototype.step = function (t) {
    this.node.opacity = this.original + this.target * t;
  };
  return e;
}(exp_FiniteTimeAction3d);
exports.FadeBy = exp_FadeBy;
var exp_CallFun3d = function (t) {
  function e(e, o, n) {
    var i = t.call(this) || this;
    i._finished = false;
    i.cb = e;
    i.target = o;
    i.data = n;
    return i;
  }
  cc__extends(e, t);
  Object.defineProperty(e.prototype, "finished", {
    get() {
      return this._finished;
    },
    enumerable: false,
    configurable: true
  });
  e.prototype.update = function () {
    if (!this.finished) {
      if (this.target) {
        this.cb.call(this.target, this.data || null);
      } else {
        this.cb(this.data || null);
      }
      this._finished = true;
    }
  };
  return e;
}(exp_Action3d);
exports.CallFun3d = exp_CallFun3d;
var exp_Sequence3d = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o.curActionPtr = 0;
    o.actions = [].concat(e);
    return o;
  }
  cc__extends(e, t);
  Object.defineProperty(e.prototype, "finished", {
    get() {
      return this.curActionPtr >= this.actions.length;
    },
    enumerable: false,
    configurable: true
  });
  e.prototype.setTarget = function (t) {
    this.node = t;
    this.setCurActionTarget();
  };
  e.prototype.update = function (t) {
    if (!this.finished) {
      var e = this.actions[this.curActionPtr];
      e.update(t);
      if (e.finished) {
        this.curActionPtr++;
        this.setCurActionTarget();
      }
    }
  };
  e.prototype.setCurActionTarget = function () {
    this.finished || this.actions[this.curActionPtr].setTarget(this.node);
  };
  e.prototype.pushAction = function (t) {
    this.actions.push(t);
  };
  return e;
}(exp_Action3d);
exports.Sequence3d = exp_Sequence3d;
var exp_Spawn3d = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o.actions = [].concat(e);
    o.remainCount = o.actions.length;
    return o;
  }
  cc__extends(e, t);
  Object.defineProperty(e.prototype, "finished", {
    get() {
      return this.remainCount <= 0;
    },
    enumerable: false,
    configurable: true
  });
  e.prototype.setTarget = function (t) {
    this.node = t;
    for (var e = this.actions.length - 1; e >= 0; --e) {
      this.actions[e].setTarget(t);
    }
  };
  e.prototype.update = function (t) {
    if (!this.finished) {
      for (var e = this.actions.length - 1; e >= 0; --e) {
        if (!this.actions[e].finished) {
          this.actions[e].update(t);
          this.actions[e].finished && this.remainCount--;
        }
      }
    }
  };
  e.prototype.pushAction = function (t) {
    this.actions.push(t);
    this.node && t.setTarget(this.node);
  };
  return e;
}(exp_Action3d);
exports.Spawn3d = exp_Spawn3d;
var _ = function () {
  function t() {}
  t.prototype.easing = function (t) {
    return t;
  };
  return t;
}();
var S = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o._rate = e;
    return o;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    return Math.pow(t, this._rate);
  };
  return e;
}(_);
var b = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o._rate = e;
    return o;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    return Math.pow(t, 1 / this._rate);
  };
  return e;
}(_);
var w = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o._rate = e;
    return o;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    if ((t *= 2) < 1) {
      return .5 * Math.pow(t, this._rate);
    } else {
      return 1 - .5 * Math.pow(2 - t, this._rate);
    }
  };
  return e;
}(_);
var P = function (t) {
  function e(e) {
    var o = t.call(this) || this;
    o._rate = e;
    return o;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    if ((t *= 2) < 1) {
      return 1 - .5 * Math.pow(2 - t, this._rate);
    } else {
      return .5 * Math.pow(t, this._rate);
    }
  };
  return e;
}(_);
var O = function (t) {
  function e() {
    return null !== t && t.apply(this, arguments) || this;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    if (0 === t) {
      return 0;
    } else {
      return Math.pow(2, 10 * (t - 1));
    }
  };
  return e;
}(_);
var C = function (t) {
  function e() {
    return null !== t && t.apply(this, arguments) || this;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    if (1 === t) {
      return 1;
    } else {
      return 1 - Math.pow(2, -10 * t);
    }
  };
  return e;
}(_);
var N = function (t) {
  function e() {
    return null !== t && t.apply(this, arguments) || this;
  }
  cc__extends(e, t);
  e.prototype.easing = function (t) {
    if (1 !== t && 0 !== t) {
      if ((t *= 2) < 1) {
        return .5 * Math.pow(2, 10 * (t - 1));
      } else {
        return .5 * (2 - Math.pow(2, -10 * (t - 1)));
      }
    } else {
      return t;
    }
  };
  return e;
}(_);